/*     */ package com.newcrm.manager;
/*     */ 
/*     */ import com.newcrm.bean.Province;
/*     */ import com.newcrm.config.ProvinceReader;
/*     */ import java.io.PrintStream;
/*     */ import java.util.List;
/*     */ import org.apache.commons.configuration.Configuration;
/*     */ import org.apache.commons.configuration.ConfigurationException;
/*     */ import org.apache.commons.configuration.PropertiesConfiguration;
/*     */ 
/*     */ public class CompanyNameManager
/*     */ {
/*  20 */   private static CompanyNameManager manager = null;
/*     */   private static final String COMPANY_NAME = "公司";
/*     */   private static final String COMPANY_CITY = "市";
/*  25 */   private List<Province> provinces = null;
/*  26 */   private String[] skipWords = null;
/*     */ 
/*     */   private CompanyNameManager()
/*     */   {
/*  30 */     ProvinceReader provinceReader = ProvinceReader.getInstance();
/*  31 */     this.provinces = provinceReader.read();
/*     */ 
/*  34 */     readSkipWord();
/*     */   }
/*     */ 
/*     */   private void readSkipWord()
/*     */   {
/*     */     try {
/*  40 */       Configuration config = new PropertiesConfiguration(
/*  41 */         "companyNameSkipWord.properties");
/*     */ 
/*  43 */       String words = config.getString("word");
/*  44 */       if ((words != null) && (words.trim().length() > 0))
/*  45 */         this.skipWords = words.split("_");
/*     */     }
/*     */     catch (ConfigurationException e1) {
/*  48 */       e1.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   public static CompanyNameManager getInstance() {
/*  53 */     if (manager == null) {
/*  54 */       manager = new CompanyNameManager();
/*     */     }
/*  56 */     return manager;
/*     */   }
/*     */ 
/*     */   public String getShortName(String name) {
/*  60 */     if ((name == null) || (name.trim().length() == 0)) {
/*  61 */       return name;
/*     */     }
/*     */ 
/*  64 */     int idx = name.indexOf("公司");
/*  65 */     if (idx <= 0) {
/*  66 */       return name;
/*     */     }
/*     */ 
/*  69 */     String shortName = name.substring(0, idx);
/*     */     String city;
/*  72 */     for (Province province : this.provinces) {
/*  73 */       idx = shortName.indexOf(province.name);
/*  74 */       if (idx > 0) {
/*  75 */         shortName = shortName.replace(province.name, "");
/*  76 */         break;
/*     */       }
/*     */ 
/*  79 */       if (province.citys != null)
/*     */       {
/*  83 */
                  for(int cNum = 0; cNum<province.citys.length;cNum++){
                      city = province.citys[cNum];
/*  84 */           city = city.replace("市", "");
/*  85 */           idx = shortName.indexOf(city);
/*  86 */           if (idx >= 0) {
/*  87 */             shortName = shortName.replace(city, "");
/*  88 */             break;
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/*     */ 
/*  94 */     if (this.skipWords != null)
/*     */     {
/*  95 */       String[] arrayOfString1;
/*  95 */       int l1 = (arrayOfString1 = this.skipWords).length;
                for (int l2 = 0; l2 < l1; l2++) {
                    String word = arrayOfString1[l2];
/*  96 */         if (word.trim().length() != 0)
/*     */         {
/*  99 */           idx = shortName.indexOf(word);
/* 100 */           if (idx >= 0) {
/* 101 */             shortName = shortName.replace(word, "");
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/* 106 */     return shortName;
/*     */   }
/*     */ 
/*     */   public static void main(String[] args) {
/* 110 */     CompanyNameManager manager = getInstance();
/* 111 */     String name = manager.getShortName("广州西客化工有限公司");
/* 112 */     System.out.println(name);
/*     */ 
/* 114 */     name = manager.getShortName("广州西客化工股份有限公司");
/* 115 */     System.out.println(name);
/*     */ 
/* 117 */     name = manager.getShortName("广州西客化工股份有限公司营业部");
/* 118 */     System.out.println(name);
/*     */ 
/* 120 */     name = manager.getShortName("广州西客化工股份有限公司（试剂销售部）");
/* 121 */     System.out.println(name);
/*     */ 
/* 123 */     name = manager.getShortName("广州西客化工股份有限公司-市场开发不");
/* 124 */     System.out.println(name);
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.manager.CompanyNameManager
 * JD-Core Version:    0.6.1
 */